<template>
    <div>
        <p>
            用户名: <input type="text" v-model="user.username">
        </p>
        <p>
            密码: <input type="text" v-model="user.password">
        </p>
        <p>
            <button @click="login">登录</button>
        </p>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import useUserStore from '@/store/modules/user'
const user = ref({ username: 'admin', password: '111111' })

const router = useRouter()

const userStore = useUserStore()
const login = async () => {
    // 调用pinia action中的方法进行登录
    await userStore.login(user.value)
    router.replace('/')
}
</script>
